package demo1;
import java.util.ArrayList;
import java.util.Iterator;
public class Test {
    public static void main(String[] args) {
                ArrayList<String> arrList = new ArrayList<String>();
                arrList.add("26565");
                arrList.add("26655");
                arrList.add("22");

                // 使用迭代器遍历ArrayList
                Iterator<String> it = arrList.iterator();
                while (it.hasNext()) {
                    String element = it.next();
                    System.out.println(element);
                }
            }
    public static void main2(String[] args) {
        ArrayList<Integer> arrList = new ArrayList<>();
        arrList.add(1);
        arrList.add(2);
        arrList.add(8);
        //循环遍历数组
        for (int i:
             arrList) {
            System.out.println(i);
        }
    }
    public static void main1(String[] args) {
        ArrayList<String> arrList = new ArrayList<>();
        arrList.add("hahah");
        arrList.add("hdbsh");
        arrList.add("回家");
        //循环遍历数组
        for (int i = 0; i < arrList.size(); i++) {
            System.out.println(arrList.get(i));
        }
    }
}

